<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class News_list extends Start_Controller {

	public function __construct(){
		parent::__construct();
		$this->load->_model('model_news','news');
	}
	
	
	public function index()
	{
		$this->_news();
	}
	public function page(){
		
	}
	
	/**
	 *  单页信息处理
	 */
	public function _news(){
		
		$classid = $this->uri->segment(2);

		
		$per_page = 10;
		
	 	$page = $this->uri->segment(3);
	 	
	     if(empty($page)){
	        $start = 0;
	     }else{
	        $start = ($page-1)*$per_page;
	     }
		
		//取得信息列表
		$data['list'] = $this->news->get_all_news_rows("classid = '$classid'",'*','id desc',$start, $per_page);
		
		//分页
		$config['base_url'] = site_url('list/'.$classid);
		$config['total_rows'] = $this->news->find_count("classid = '$classid'");
		$config['per_page'] = $per_page;
		$config['uri_segment'] = 3;
		//分页数据显示的标签
		$config['full_tag_open'] = '<div>';
		$config['full_tag_close'] = '</div>';
		//当前页的其实标签 ?: 加粗一下
		$config['cur_tag_open'] = '<b>';
		$config['cur_tag_close'] = '</b>';
		$config['prev_link'] = '上一页';
		$config['next_link'] = '下一页';
		$config['use_page_numbers'] = TRUE;
		//当前页先后个显示的个数
		$config['num_links'] = 9;
		
		$this->load->library('pagination'); //载入分页类
		$this->pagination->initialize($config); 
		$page = $this->pagination->create_links();
		
		$data['page'] =  $page;
		
		if(isset($data['list'][0]['classname']))
		{
			//获取单页信息
			$this->data['pagename'] = $data['list'][0]['classname'];
			
		}
		else
		{
			$data['list'];
		}
		$this->data['list'] = $data['list'];
		$this->data['page'] = $data['page'];
		$this->data['leftmenu'] = get_tclass('news');   //全部文章分类
		$this->data['classname'] = $this->news->get_info_class($classid);
		$this->data['classid'] = $classid;
		
		
		$this->_template('list',$this->data);
		
		
		
		
		
		
	 
		
    }
 
    
	
	
	
}









